<?PHP	
	require 'config.php';
	require 'SimpleImage.php';
	
	function DoReplace($AName, $ASource, $ADestination, $AFolders, $APrefixes)
	{
		if(isset($AFolders[$ASource]) and isset($AFolders[$ADestination]))
		{
			foreach ($APrefixes as $vPrefix)
			{
				$vFileName = $vPrefix . $AName . '.jpg';
				$vSource = $AFolders[$ASource] . $vFileName;
				if(file_exists($vSource))
				{
					$vDestination = $AFolders[$ADestination] . $vFileName;
					rename($vSource, $vDestination);
				}
			}
		}		
	}
	
	function DoRotate($AName, $ASource, $ARotation, $AFolders, $APrefixes)
	{
		if(isset($AFolders[$ASource]))
		{
			$image = new SimpleImage();			
			foreach ($APrefixes as $vPrefix)
			{
				$vName = $AFolders[$ASource] . $vPrefix . $AName . '.jpg';
				
				if(file_exists($vName))
				{
					$image->load($vName);
					$image->rotate($ARotation);
					$image->save($vName, IMAGETYPE_JPEG);
					$image->destroyImage();
				}			
			}			
			unset($image);
		}				
	}
?>